from django.shortcuts import render

# Create your views here.
from rest_framework.generics import ListAPIView
from rest_framework.permissions import IsAuthenticated
from .models import UserCoupon
from .serializers import UserCouponModelSerializer

class UserCouponAPIView(ListAPIView):
    # queryset = UserCoupon.objects.filter(is_show=True, is_deleted=False, is_use=False)
    permission_classes = [IsAuthenticated]
    serializer_class = UserCouponModelSerializer
    # 获取用户
    def get_queryset(self):
        """ 获取当前的用户
            写了get_queryset queryset这个就可以忽略了
        """
        return UserCoupon.objects.filter(is_show=True, is_deleted=False,is_use=False, user_id=self.request.user.id)